﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testtoken.aspx.cs" Inherits="testtoken" %>
<%@ Import Namespace="m.avis.cn" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <%= TokenCache.Token %>

        <script type="text/javascript">
            var tokn = <%= TokenCache.Token %>;
            function showToken() {
                alert(tokn);

            }
            function callAPI() {
                $.ajax({

                    type: "get",
                    url: "http://localhost:5001/identity",
                    beforeSend: function (xhr) {

                        xhr.setRequestHeader("Authorization", "Basic " + JSON.parse(tokn).access_token);

                    },
                    success: function (data) { alert(data); },
                    error: function (data) { alert("error"); }
                });

            }
        </script>
        <div>
            <input type="button" value="showToken" onclick="showToken();"/>
            <input type="button" value="callAPI" onclick="callAPI();"/>
        </div>
    </form>
</body>
</html>
